import React from "react";
import classNames from "classnames";
import { prefixCls } from "../constant";

export interface PageItemProps {
  page: number;
  active: boolean;
  onClick?: (page: number) => void;
}

const PageItem: React.VFC<PageItemProps> = (props) => {
  const { page, active, onClick } = props;
  const classname = `${prefixCls}-item`;

  return (
    <li
      title={`${page}`}
      onClick={() => onClick && onClick(page)}
      className={classNames(classname, active && `${classname}-active`)}
    >
      <a rel="nofollow">{page}</a>
    </li>
  );
};

export default PageItem;
